import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class 购物单 {
    public static void main(String[] args) throws IOException {
        //创建一个输入流录取文本的数据
        BufferedReader br = new BufferedReader(new FileReader("D:\\javastudy\\juny\\src\\ingf.txt"));
        String line;
        //创建匹配商品金额和折扣的正则表达式
        String regex = "(([半|0-9]{1,2}[折价])|(\\d+.\\d{2}))";
        //创建一个变量记录要支付的钱
        double count = 0;
       while ((line = br.readLine())!= null) {
           //创建正则化表达式的文本匹配器的对象
           Matcher m = Pattern.compile(regex).matcher(line);
           //创建一个变量记录先匹配到的金额
           m.find();
           Double money = Double.parseDouble(m.group());
           //根据文本转化对应的折扣为数字
           m.find();
           String group = m.group();
           double dazhe = dazhe(group);
           count+=money*dazhe;
       }
        System.out.println(count);
    }

    private static double dazhe(String group) {
        if (group.endsWith("折")||group.endsWith("价")){
            //截取这前面的数字
            group = group.substring(0, group.length()-1);
            if (group.equals("半")){
                return 0.5;
            }
            int i = Integer.parseInt(group);
            if (i>10){
                return (double) i/100;
            }else {
                return (double) i/10;            }
        }
        return -1;
    }
}
